package com.changgou.goods.feign;

import com.changgou.goods.pojo.Sku;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * <dl>
 * <dd>描述: ~节点业务逻辑实现</dd>
 * <dd>创建时间：  11:36 2020/4/5</dd>
 * <dd>创建人： zz</dd>
 * <dt>版本历史: </dt>
 * <pre>
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2020/4/5      guodong       1.0        1.0 Version
 * </pre>
 * </dl>
 */
@FeignClient(name = "goods")
@RequestMapping("/sku")
public interface SkuFeign {

    @GetMapping("/findSkuListBySpuId/{spuId}")
    List<Sku> findSkuListBySpuId(@PathVariable("spuId") String spuId);

    @GetMapping
    List<Sku> findAll();

    @GetMapping("/one/{id}")
    public Sku findOneById(@PathVariable(value = "id") String id);

    /**
     * 扣减库存, 增加销量
     * @param skuId     购买商品的库存id
     * @param num       购买了多少件
     * @return
     */
    @GetMapping("/decrCount")
    public Boolean decrCount(@RequestParam(value = "skuId") String skuId,
                             @RequestParam(value = "num")Integer num);


    /**
     * 恢复库存, 恢复销量
     * @param skuId     购买商品的库存id
     * @param num       购买了多少件
     * @return
     */
    @GetMapping("/incrCount")
    public Boolean incrCount(@RequestParam(value = "skuId") String skuId,
                             @RequestParam(value = "num")Integer num);
}
